import pandas as pd

def predict_tip():
    # 读取数据
    input_data = input().split()
    sex = 'Male' if input_data[0] == '1' else 'Female'
    smoker = 'Yes' if input_data[1] == '1' else 'No'
    day_num = int(input_data[2])
    time = 'Dinner' if input_data[3] == '1' else 'Lunch'
    total_bill = float(input_data[4])
    
    # 星期数集
    day_map = {
        0: 'Sun',
        1: 'Mon',
        2: 'Tue',
        3: 'Wed',
        4: 'Thu',
        5: 'Fri',
        6: 'Sat'
    }
    day = day_map.get(day_num, 'Sun')
    
    # 重载数据集
    fdata = pd.read_csv('tips.csv')
    fdata.rename(columns={
        'total_bill': '消费总额',
        'tip': '小费',
        'sex': '性别',
        'smoker': '是否抽烟',
        'day': '星期',
        'time': '聚餐时间段',
        'size': '人数'
    }, inplace=True)
    
    # 计算整体平均小费比例
    overall_avg_ratio = (fdata['小费'] / fdata['消费总额']).mean()

    # 过滤出有用的数据
    filtered = fdata[
        (fdata['性别'] == sex) &
        (fdata['是否抽烟'] == smoker) &
        (fdata['星期'] == day) &
        (fdata['聚餐时间段'] == time)
    ].copy()  
    
    # 计算平均小费比例
    if not filtered.empty:
        filtered.loc[:, '小费比例'] = filtered['小费'] / filtered['消费总额']
        avg_ratio = filtered['小费比例'].mean()
    else:
        avg_ratio = overall_avg_ratio
    
    # 计算小费
    predicted_tip = round(total_bill * avg_ratio, 2)
    
    # 输出
    print("{:.2f}".format(predicted_tip))

predict_tip()